package com.ttg.web.controller.common;

import com.ttg.common.entities.BaseResult;
import com.ttg.common.utils.RequestParamsManager;
import com.ttg.model.dto.*;
import com.ttg.model.dto.open.MemberConfigBindTagListDto;
import com.ttg.web.service.VipGradeConfigService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author zhangHongYuan
 * @description
 * @date 2023/7/6 14:52
 */
@Api("会员等级配置")
@RestController
@RequestMapping("/vipGrade")
public class VipGradeConfigController {

     @Autowired
     private VipGradeConfigService vipGradeConfigService;

    /**
     * 会员配置列表
     * @param data
     * @return BaseResult
     *@author zhangHongYuan
     *@date 2023/6/7 10:36+0
     */
    @PostMapping("/config/list")
    public BaseResult getMemberGradeConfigList(@RequestBody String data){
        MemberConfigListDto memberConfigListDto = RequestParamsManager.transformRequestParam(data, MemberConfigListDto.class);
        return vipGradeConfigService.getMemberConfigList(memberConfigListDto);
    }

    /**
     * 添加会员配置
     * @param data
     * @return BaseResult
     *@author zhangHongYuan
     *@date 2023/6/7 10:36
     */
    @PostMapping("/config/addOrEdit")
    public BaseResult addOrEditMemberGradeConfig(@RequestBody String data){
        MemberConfigAddOrUpdateDto dto = RequestParamsManager.transformRequestParam(data , MemberConfigAddOrUpdateDto.class);
        return vipGradeConfigService.addOrEditMemberGradeConfig(dto);
    }


    /**
     * 会员配置不能删除可以新增编辑,上限十条避免吗权益在使用会员等级时候被删除
     * 删除会员配置
     * @param data
     * @return
     *//*
    @PostMapping("/config/delete")
    public BaseResult deleteMemberGradeConfig(@RequestBody String data){
        MemberConfigDeleteDto2 memberConfigAddDto = RequestParamsManager.transformRequestParam(data, MemberConfigDeleteDto2.class);
        return vipGradeConfigService.deleteMemberGradeConfig(memberConfigAddDto);
    }*/

    /**
     * 会员权益
     * @param data
     * @return
     */
    @PostMapping("/config/equity")
    public BaseResult equity(@RequestBody String data){
        VipEquityDto vipEquityDto = RequestParamsManager.transformRequestParam(data, VipEquityDto.class);
        return vipGradeConfigService.equity(vipEquityDto);
    }

    @PostMapping("/config/select")
    public BaseResult selectMemberGradeConfig(@RequestBody String data){
        MemberConfigDeleteDto memberConfigAddDto = RequestParamsManager.transformRequestParam(data, MemberConfigDeleteDto.class);
        return vipGradeConfigService.selectMemberGradeConfig(memberConfigAddDto);
    }

    /**
     * 获取会员等级编号与会员等级名称对应关系列表
     * @return
     */
    @PostMapping("/getVipGradeNameList")
    public BaseResult getVipGradeNameList(@RequestBody String data){
        HashMap map = RequestParamsManager.transformRequestParam(data, HashMap.class);
        return vipGradeConfigService.getVipGradeNameList(map);
    }

    @PostMapping("/config/qureyBind")
    public BaseResult queryBindGradeTags(@RequestBody String data){
        MemberConfigBindTagListDto memberConfigAddDto = RequestParamsManager.transformRequestParam(data, MemberConfigBindTagListDto.class);
        return vipGradeConfigService.queryBindGradeTags(memberConfigAddDto);
    }

    @PostMapping("/config/queryTag")
    public BaseResult queryTagsForBind(@RequestBody String data){
        MemberConfigBindTagListDto memberConfigAddDto = RequestParamsManager.transformRequestParam(data, MemberConfigBindTagListDto.class);
        return vipGradeConfigService.queryTagsForBind(memberConfigAddDto);
    }
}
